package artid.com.arttogo.adapter;

import android.app.Activity;
import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.View.OnClickListener;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.ImageView;
import android.widget.TextView;

import com.bumptech.glide.Glide;

import java.util.List;

import artid.com.arttogo.R;
import artid.com.arttogo.bean.AuctionMyNoteParser;
import artid.com.arttogo.utils.MyBitmapImageViewTarget;
import artid.com.arttogo.utils.NetUtils;

/**
 * 
 *    
 * 项目名称：ArtworkArt   
 * 类名称：AuctionMyNote_Adapter   
 * 类描述：我的笔记适配器   
 * 创建人：耿卫斌   
 * 创建时间：2017-4-1 上午11:20:28   
 *
 */
public class AuctionMyNote_Adapter extends BaseAdapter {
	private Context mContext;
	public List<AuctionMyNoteParser> list;

	public AuctionMyNote_Adapter(Context mContext,
								 List<AuctionMyNoteParser> list) {
		super();
		this.mContext = mContext;
		this.list = list;
	}

	@Override
	public int getCount() {
		// TODO Auto-generated method stub
		return list.size();
	}

	@Override
	public Object getItem(int position) {
		// TODO Auto-generated method stub
		return list.get(position);
	}

	@Override
	public long getItemId(int position) {
		// TODO Auto-generated method stub
		return position;
	}

	@Override
	public View getView(final int position, View convertView, ViewGroup parent) {
		// TODO Auto-generated method stub
		ViewHolder holder = null;
		View v = convertView;
		if (v == null) {
			holder = new ViewHolder();
			v = LayoutInflater.from(mContext).inflate(R.layout.item_auctionmynote, null);
			holder.content=(TextView) v.findViewById(R.id.itemAuctionMyNote_content);
			holder.company=(TextView) v.findViewById(R.id.itemAuctionMyNote_company);
			holder.address=(TextView) v.findViewById(R.id.itemAuctionMyNote_address);
			holder.special=(TextView) v.findViewById(R.id.itemAuctionMyNote_special);
			holder.time=(TextView) v.findViewById(R.id.itemAuctionMyNote_time);
			holder.img=(ImageView) v.findViewById(R.id.itemAuctionMyNote_img);
			holder.imgTitle=(TextView) v.findViewById(R.id.itemAuctionMyNote_imgTitle);
			holder.editBtn=(TextView) v.findViewById(R.id.itemAuctionMyNote_editBtn);
			holder.deleteBtn=(TextView) v.findViewById(R.id.itemAuctionMyNote_deleteBtn);
			v.setTag(holder);
		} else {
			holder = (ViewHolder) v.getTag();
		}
		holder.content.setText(list.get(position).getDescribe());
		holder.company.setText(list.get(position).getSeller_name());
		holder.address.setText(list.get(position).getAddress());
		holder.special.setText(list.get(position).getTitle());
		holder.time.setText(list.get(position).getCreate_time());
		Glide.with(mContext).load(list.get(position).getImgurl()
				+ "_"+ (Integer.parseInt(NetUtils.getDisplayMetrics((Activity)mContext).get(NetUtils.DM_WIDTH)) /2) + "x10.png"
				).asBitmap().centerCrop()
				.placeholder(R.drawable.ic_menu_rotate).error(R.drawable.ic_menu_rotate)
				.into(new MyBitmapImageViewTarget(holder.img));
		holder.imgTitle.setText(list.get(position).getLot_name());
		holder.editBtn.setOnClickListener(new OnClickListener() {
			
			@Override
			public void onClick(View v) {
				// TODO Auto-generated method stub
				//编辑
				
			}
		});
		holder.deleteBtn.setOnClickListener(new OnClickListener() {
			
			@Override
			public void onClick(View v) {
				// TODO Auto-generated method stub
				//删除
				
			}
		});
		return v;
	}
	class ViewHolder {
		ImageView img;
		TextView content,company,address,special,time,imgTitle,editBtn,deleteBtn;
	}
}
